package com.hr.controller;


import com.hr.entity.Product;
import com.hr.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * InnoDB free: 11264 kB 前端控制器
 * </p>
 *
 * @author jobob
 * @since 2020-11-06
 */

@RestController
@RequestMapping("/product")
public class ProductController {

    @Autowired
    private IProductService productService;

    @GetMapping("")
  public List<Product> getProductList(){

      return productService.list();
  }

   @GetMapping("/{pid}")
  public Product selectById(@PathVariable("pid") Integer pid){
        return  productService.getById(pid);
   }

   @PostMapping("")
    public Boolean add(Product product){
        return productService.save(product);
   }

   @DeleteMapping("/{pid}")
    public Boolean del(@PathVariable("pid") Integer pid){
       return  productService.removeById(pid);
   }

   @PutMapping("")
    public boolean update(Product product){
    return  productService.updateById(product);
   }
}